﻿using System;
using System.Collections.Generic;
using Castle.ActiveRecord;
using CostTrade.Core.Data;
using Natrue.Data.FastMapping;

namespace CostTrade.BusinessLayer
{
    /// <summary>
    /// 采购单
    /// </summary>
    [ActiveRecord("tbStockOrder"), Serializable]
    public class StockOrder : CBBase
    {
        private readonly Guid primaryKey = Guid.NewGuid();
        [PrimaryKey(PrimaryKeyType.Assigned, "ROWGUID", Access = PropertyAccess.NosetterCamelcase), Mark("采购单编号")]
        public override Guid PrimaryKey
        {
            get { return primaryKey; }
        }

        /// <summary>
        /// 采购单编号  
        /// </summary>
        private string orderId;
        /// <summary>
        /// 下单日期
        /// </summary>
        private DateTime makeDate=new DateTime(1970,0,0);
        /// <summary>
        /// 供应商
        /// </summary>
        private string supplier;
        /// <summary>
        /// 联系方式
        /// </summary>
        private string content;
        /// <summary>
        /// 采购数量
        /// </summary>
        private int stockCount;
        /// <summary>
        /// 采购单总价
        /// </summary>
        private double stockValues;
        /// <summary>
        /// 采购商品列表
        /// </summary>
        IList<StockWares> stockWaresList = new List<StockWares>();
        /// <summary>
        /// 已付款金额
        /// </summary>
        private double hasPayMoney;
        /// <summary>
        /// 付款状态
        /// </summary>
        private PayState orderPayState;

        /// <summary>
        /// 采购单编号  
        /// </summary>
        [Property, Mark("采购单编号",IsNotNull=true)]
        public string OrderId
        {
            get { return orderId; }
            set { orderId = value; }
        }

        /// <summary>
        /// 下单日期
        /// </summary>
        [Property, Mark("下单日期", IsNotNull = true)]
        public DateTime MakeDate
        {
            get { return makeDate; }
            set { makeDate = value; }
        }

        /// <summary>
        /// 供应商
        /// </summary>
        [Property, Mark("供应商")]
        public string Supplier
        {
            get { return supplier; }
            set { supplier = value; }
        }

        /// <summary>
        /// 联系方式
        /// </summary>
        [Property, Mark("联系方式")]
        public string Content
        {
            get { return content; }
            set { content = value; }
        }

        /// <summary>
        /// 采购数量
        /// </summary>
        [Property, Mark("采购数量")]
        public int StockCount
        {
            get { return stockCount; }
            set { stockCount = value; }
        }

        /// <summary>
        /// 采购单总价
        /// </summary>
        [Property, Mark("采购单总价")]
        public double StockValues
        {
            get { return stockValues; }
            set { stockValues = value; }
        }

        /// <summary>
        /// 采购商品列表
        /// </summary>
        [HasAndBelongsToMany(typeof(StockWares), Access = PropertyAccess.NosetterCamelcase, ColumnKey = "StockOrderId", ColumnRef = "WaresId", Table = "tbStockOrderAndWares"), Mark("采购商品列表")]
        public IList<StockWares> StockWaresList
        {
            get { return stockWaresList; }
        }

        /// <summary>
        /// 已付款金额
        /// </summary>
        [Property, Mark("已付款金额")]
        public double HasPayMoney
        {
            get { return hasPayMoney; }
            set { hasPayMoney = value; }
        }

        /// <summary>
        /// 付款状态
        /// </summary>
        [Property, Mark("付款状态")]
        public PayState OrderPayState
        {
            get { return orderPayState; }
            set { orderPayState = value; }
        }
    }
}